import requests
import json
import execjs
with open("login.js", "r", encoding="utf-8") as f:
    js_code = f.read()

# 编译JS代码
ctx = execjs.compile(js_code)

headers = {
    "Accept": "application/json, text/javascript, */*; q=0.01",
    "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,ar;q=0.7",
    "Cache-Control": "no-cache",
    "Connection": "keep-alive",
    "Content-Type": "application/json",
    "Origin": "https://passport.mygjp.com.cn",
    "Pragma": "no-cache",
    "Referer": "https://passport.mygjp.com.cn/",
    "Sec-Fetch-Dest": "empty",
    "Sec-Fetch-Mode": "cors",
    "Sec-Fetch-Site": "same-origin",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36 Edg/137.0.0.0",
    "X-Requested-With": "XMLHttpRequest",
    "sec-ch-ua": '"Microsoft Edge";v="137", "Chromium";v="137", "Not/A)Brand";v="24"',
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": '"Windows"',
}
cookies = {
    "acw_tc": "3ccdc14117509337743411379e7d1b04e690ec567148b873ef3fe45864c62b",
    "_ati": "1747430260663",
    "3AB9D23F7A4B3C9B": "FUYJZTK36DSCMQGWN46LVOZX22KVFQDGDFBBVYTNBTZFLA6KLWLRN37T2STWYFAVUK52CHCMJ2VD2XWIL7IO34DARU",
    "pati": "1QXjvs3kzsPiFzSEjJs6wDkwUWGLIwXS",
}
url = "https://passport.mygjp.com.cn/api/ngpLogin"
usn="fbike2985"
pwd="12345678"
dataa=ctx.call("get_enc",usn,pwd)
password=dataa["password"]
userName=dataa["user"]
data = {
    "userName": userName,
    "password": password,
    "companyName": "腾讯",
    "validateCode": "",
    "validateId": "",
    "deviceId": "FUYJZTK36DSCMQGWN46LVOZX22KVFQDGDFBBVYTNBTZFLA6KLWLRN37T2STWYFAVUK52CHCMJ2VD2XWIL7IO34DARU",
    "ati": "1747430260663",
    "pati": "1QXjvs3kzsPiFzSEjJs6wDkwUWGLIwXS",
    "https": True,
    "loginType": None,
}
data = json.dumps(data, separators=(",", ":"))
response = requests.post(url, headers=headers, cookies=cookies, data=data)
print(response)
print(response.text)
